package com.qf.flash.mvp.presenter;

import com.qf.flash.http.HttpManager;
import com.qf.flash.model.VideoListBean;
import com.qf.flash.mvp.contract.VideoContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class VideoListPresenter extends BasePresenter<VideoContract.View> implements VideoContract.Presenter {
    @Override
    public void getVideos(int pageNo, int pageSize) {

        addSubscription(HttpManager.getInstance().getGsonHttpApi()
            .GET_VIDEO_LIST(pageNo,pageSize)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<VideoListBean>>>(mRootView){

                    @Override
                    public void onSuccess(BaseResponse<List<VideoListBean>> listBaseResponse) {
                        mRootView.setShowDatas(listBaseResponse.getData(),listBaseResponse.getTotalPage());
                    }
                })
        );
    }
}
